perf(pos-app): speed up amount entry on low-end devices - #640
ignaciosantise wants to merge 2 commits into
Conversation
- Keep the keypad's onKeyPress stable (plain useState + functional update) so the memoized NumericKeyboard no longer re-renders all 12 keys per press; drops react-hook-form, which only this screen used. - Cache decimal/group separators per locale instead of constructing three Intl.NumberFormat instances per keypress (slow on Android Hermes). - Enable Reanimated's synchronous UI-prop updates so transform/opacity animations skip the per-frame shadow-tree commit. - Render amount characters with a plain Text. Measured on a low-end Android POS terminal (MT6761): per-key JS work 77ms -> 37ms, keypress -> next frame 103ms -> 60ms. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
2 Skipped Deployments
|
|
Claude finished @ignaciosantise's task in 2m 36s —— View job Code Review
License compliance: ✅ No issues — Breaking changes: ✅ No breaking changes — all exported symbols and component contracts are unchanged; Found 2 issue(s)Issue 1: Unnecessary
|
Drop IOS_SYNCHRONOUSLY_UPDATE_UI_PROPS: the per-frame shadow-tree commit cost was only measured on low-end Android hardware, and the flag changes every Reanimated animation on iOS. Also remove the keypad's handlePress pass-through wrapper. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Summary
Makes the amount screen respond faster on low-end Android POS hardware. The existing
BigAmountInputanimation and visuals are unchanged.app/amount.tsxnow uses plainuseStatewith a stableonKeyPress. Before, a new inline handler on every render stopped the memoizedNumericKeyboardfrom skipping renders, so all 12 keys re-rendered on each press. This removesreact-hook-form, which only this screen used; the lockfile change is just its own entries.formatAmount.tslooks up the decimal and group separators once per locale. Before, each key press built threeIntl.NumberFormatinstances, which is slow on Android Hermes because it goes through Java ICU.ANDROID_SYNCHRONOUSLY_UPDATE_UI_PROPSis turned on inpackage.json. A Perfetto profile showed about 37% of the UI thread going to Reanimated committing the full shadow tree on every animation frame. With the flag, transform and opacity updates skip that commit. The iOS equivalent is deliberately left off: that cost was only measured on low-end Android, and the flag would change every Reanimated animation on iOS.AnimatedCharacter: plainTextinstead ofAnimated.Text.Measurements
Release builds on a low-end Android POS terminal (MediaTek MT6761, 4× Cortex-A53, 1.8 GB RAM). A scripted
adbtyping sequence (1234567.89then 10 backspaces) ran ×5 per run, 3 baseline runs vs 2 final runs.The janky-frame % under rapid typing did not change (~14%).
Testing
main, and every scripted tap registeredtranslateXanchor, which broke iOS; it was reverted.npm test(309 passing), lint, type checkNative config changed on Android (Reanimated static flag), so Android builds need a clean prebuild. iOS native is unchanged.
🤖 Generated with Claude Code